<!--
    @name 索赔结算明细
    @author haoyang.ding
    @date 2021-2-24
-->
<template>
  <section>
    <div class="filter-container filter-title">结算信息</div>
    <OneTableTemplate
      :dynamic-components="formInputs"
      :dynamic-form-fields="formField"
    />
    <div
      class="filter-container filter-title"
    >
      索赔信息
    </div>
    <OneTableTemplate
      ref="queryXinhy"
      :dynamic-table-cols="tableHeader_1"
      :dynamic-is-show-select="false"
      :is-show-pagination="false"
    />
    <div class="filter-container filter-title">倒扣信息</div>
    <OneTableTemplate
      ref="queryInvert"
      :dynamic-table-cols="tableHeader_2"
      :dynamic-is-show-select="false"
      :is-show-pagination="false"
    />

    <edit
      :key="editPopupsKey"
      :dynamic-edit-row-data="editRowData"
      :popups-visible="editPopupsVisible"
      :popups-state="editPopupsState"
      :dynamic-api-style="'restful'"
      @close="close"
    />
  </section>
</template>

<script>
import OneTableTemplate from '@/components/templates/oneTable'
import { orgApis } from '@/api/apiClaimMangemet'
import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
export default {
  name: 'ClaimSettlementSearch',
  components: {
    OneTableTemplate,
    Edit: () => import('@/views/se/ClaimManagement/ClaimDeduction/edit')
  },
  mixins: [oneTableWithViewTemplateMixins],
  data() {
    return {
      listView: {},
      editRowData: {},
      selectData: {},
      editPopupsVisible: false,
      //   dynamicApiConfigs: orgApis.queryClaimDetail,
      formInputs: [
        {
          compKey: 'key0',
          labelName: '门店编码：',
          codeField: 'dlrCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
		  type: 'inputText',
		  disabled: true,
          isMust: true
        },
        {
          compKey: 'key1',
          labelName: '门店名称：',
          codeField: 'dlrFullName',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
		  type: 'inputText',
		  disabled: true,
          isMust: true
        },
        {
          compKey: 'key2',
          labelName: '结算单号：',
          codeField: 'repairBalanceCode',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
		  type: 'inputText',
		  disabled: true,
          isMust: true
        },
        {
          compKey: 'key3',
          labelName: '结算批次：',
          codeField: 'balanceMonth',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
		  type: 'inputText',
		  disabled: true,
          isMust: true
        },
        {
          compKey: 'key4',
          labelName: '索赔金额：',
          codeField: 'amountIncludeOldfee',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
		  type: 'inputText',
		  disabled: true,
          isMust: true
        },
        {
          compKey: 'key5',
          labelName: '倒扣金额：',
          codeField: 'reverseAmount',
          isMul: false,
          component: () => import('@/components/org/commonInput'),
		  type: 'inputText',
		  disabled: true,
          isMust: true
        }
      ],
      tableHeader_1: [
        {
          prop: 'controlBtn',
          label: '操作', // 操作
          codeField: 'orgName',
          width: null,
          align: 'center',
          isComponent: true,
          comps: [
            {
              compKey: 'propKey0',
              align: 'center',
              labelName: '查看',
              codeField: 'orgName',
              component: () => import('@/components/org/linkButton'),
              clickEvent: (index) => this.goviewPage(index)
            }
          ]
        },
        {
          label: '索赔单号',
          prop: 'claimCode'
        },
        {
          label: '索赔分类',
          prop: 'claimType'
        },
        {
          label: '申请日期',
          prop: 'createdDate'
        },
        {
          label: '索赔单状态',
          prop: 'claimStatus'
        },
        {
          label: '索赔金额',
          prop: 'amountIncludeOldfee'
        },

        {
          label: '派工单号',
          prop: 'repairOrderCode'
        },
        {
          label: '活动/同意编号',
          prop: 'agreeNO'
        },
        {
          label: '车牌号',
          prop: 'carLicense'
        },
        {
          label: '车主名称',
          prop: 'custName'
        },
        {
          label: '车主电话',
          prop: 'phone'
        },
        {
          label: '销售日期',
          prop: 'saleDate'
        },

        {
          label: '行驶里程',
          prop: 'mileage'
        },
        {
          label: '审核人',
          prop: 'auditUser'
        },
        {
          label: '审核时间',
          prop: 'auditMemo'
        },
        {
          label: '审核意见',
          prop: ''
        }
      ],
      tableHeader_2: [
        {
          prop: 'controlBtn',
          label: '操作', // 操作
          codeField: 'orgName',
          width: null,
          align: 'center',
          isComponent: true,
          comps: [
            {
              compKey: 'propKey0',
              align: 'center',
              labelName: '查看',
              codeField: 'orgName',
              clickEvent: (index) => {
                // this.$router.push({ name: "settlementdeduction" });
                this.look(index)
              },
              component: () => import('@/components/org/linkButton')
            }
          ]
        },
        {
          label: '倒扣单号',
          prop: 'reverseCode'
        },
        {
          label: '申请日期',
          prop: 'createdDate'
        },
        {
          label: '索赔单号',
          prop: 'claimCode'
        },
        {
          label: '索赔分类',
          prop: 'claimType'
        },
        {
          label: '倒扣原因',
          prop: 'reason'
        },

        {
          label: '状态',
          prop: 'reverseStatus'
        },
        {
          label: '索赔金额',
          prop: 'amountIncludeOldfee'
        },
        {
          label: '应扣金额',
          prop: 'yetAmount'
        },
        {
          label: '实扣金额',
          prop: 'buckledAmount'
        },
        {
          label: '申请人',
          prop: ''
        },
        {
          label: '审核人',
          prop: 'dkauditUser'
        },
        {
          label: '审核意见',
          prop: 'dkauditDate '
        }
      ],
      formField: {
        dlrCode: '',
        dlrFullName: '',
        repairBalanceCode: '',
        balanceMonth: '',
        amountIncludeOldfee: '',
        reverseAmount: ''
      }
    }
  },
  mounted() {
    this.listView = this.$route.params
    for (const i in this.formField) {
      this.formField[i] = this.listView[i]
    }
    console.log(this.listView, 'this.listView')
    this.queryMore()
  },
  methods: {
    goviewPage(index) {
      const info = this.$refs['queryInvert'].list[index]
      // let paramsData={ claimCode: this.$refs["multipleTable"].list[index].claimCode,viewEdit:'view'}
      const paramsData = { viewEdit: 'view' }
      paramsData.claimCode = info.claimCode
      this.$router.push({
        name: 'claimApplicationDetails',
        params: paramsData
      })
    },
    look(index) {
      this.editPopupsState = 'look'
      this.editPopupsVisible = true
      this.editRowData = this.$refs['queryInvert'].list[index]
    },
    close() {
      this.editPopupsVisible = false
      this.queryTable(1)
    },
    queryMore() {
	  const info = {}
	  info.repairBalanceCode = this.listView.repairBalanceCode
      const that = this
      const queryObj = {
        apiConfig: orgApis.queryClaimDetail,
        // 条件/实体参数（变量），根据typeParam中的定义配置
        variables: {
          // 当前中台使用的名称有dataInfo、info，具体查看API文档
        //    dataInfo: info,
        }
      }
      // 转换了中台请求格式数据
      var paramD = that.$getParams(queryObj)
      //   调用中台API方法（可复用）
      that.$requestAPI(paramD).then((response) => {
        if (response.result === '0') {
          return
        }
        var getResult = response
        if (getResult.result === '1') {
		  console.log('111')
		  that.$refs.queryXinhy.list = getResult.rows[0].claimList
		  that.$refs.queryInvert.list = getResult.rows[0].dkList
          // 重置表单
          // that.resetRight(tableRef)
          // 重新加载
        //   that.onLeftRowClick(null);
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
